#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12 height-auto">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                        <input type="text" id="type_code" lay-verify="required" placeholder="分类ID" autocomplete="off"
                               class="table-search-text width120">
                        <input type="text" id="type_name" lay-verify="required" placeholder="分类名称" autocomplete="off"
                               class="table-search-text width200">
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>
                    </p>
                    <i class="layui-icon layui-icon-slider"></i>
                    当前位置 > <span class="color_green">系统分类列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container">
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="AddSystemType">
                                <i class="layui-icon">&#xe608;</i> 添加系统分类
                            </button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSystemType">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="DelSystemType">删除</button>
                            <button class="layui-btn layui-btn-sm btn-search-adv" lay-event="InitSystemType">
                                <i class="layui-icon">&#xe9aa;</i>清除缓存
                            </button>
                        </div>
                    </script>

                    <script type="text/html" id="table_1_bar1">
                        <a class="layui-btn layui-btn-xs btn-change-13" lay-event="Edit">分类配置</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">
    layui.use(['myTable', 'table', 'form', 'util', 'myTool'], function () {
        table = layui.table, myTable = layui.myTable, form = layui.form;
        tableindex = myTable.render({
            url: 'SystemTypeDataApi'
            , title: '系统测试列表'
            , cols: [[
                {type: 'checkbox', width: 36, fixed: true}
                , {field: 'type_code', title: '分类ID', width: 180}
                , {field: 'sindex', title: '顺序', width: 80, align: 'center', sort: true}
                , {field: 'type_name', title: '分类名称', width: 200}
                , {field: 'type_desc', title: '备注说明', hide: false}
                , {fixed: 'right', title: '操作', toolbar: '#table_1_bar1', width: 120, align: 'center'}
            ]]
            , page: true, limit: 10
        });

        layui.util.event("lay-event", {
            SearchReload: function () {
                tableindex.reload({});
            },
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        like: {type_code: $("#type_code").val(), type_name: $("#type_name").val()}
                    }
                    , page: {curr: 1}
                });
            }
        });

        //头工具栏事件
        table.on('toolbar(table_1)', function (obj) {
            layui.myTool.toolbar(this, obj, {
                AddSystemType: function () {
                    index = top.layer.open({
                        type: 2, offset: '100px', title: ['添加分类', 'font-size:15px;'], area: ['800px', '550px'],
                        content: ["systype/AddSystemType", 'no']
                        , end: function () {
                            tableindex.reload();
                        }
                    });
                }
                , EditSystemType: function (obj) {
                    layui.myTool.doSingleSelect(table.checkStatus('table_1'), {key: ''}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '100px', title: ['修改分类', 'font-size:15px;'], area: ['800px', '550px'],
                            content: ["systype/EditSystemType?type_code=" + data[0].type_code, 'no']
                            , end: function () {
                                tableindex.reload();
                            }
                        });
                    });
                }
                , DelSystemType: function () {
                    layui.myTool.doSingleSelect(table.checkStatus('table_1'), {key: ''}, function (data, keys) {
                        index = layer.confirm('你是否确认删除【' + data[0].type_name + '】', {icon: 3, title: '提示', offset: '100px'}, function (index2) {
                            layui.myTool.postMsg("DelSystemTypeApi", {type_code: data[0].type_code}, function () {
                                tableindex.reload();
                            })
                        })
                    });
                }
                , InitSystemType: function () {
                    index = top.layer.confirm('你是否确认重置缓存？', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                        layui.myTool.postMsg("InitSystemType", {}, function () {
                            tableindex.reload();
                        });
                    });
                }
            });
        });

        //监听行工具事件
        table.on('tool(table_1)', function (obj) {
            layui.myTool.tool(this, obj, {
                Edit: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '60px', title: ['设置分类明细', 'font-size:15px;'], area: ['800px', '550px'],
                        content: ["systype/SystemTypeDetailList?type_code=" + data.type_code, 'no']
                        , end: function () {
                            tableindex.reload();
                        }
                    });
                }
            });
        });
    });
</script>
</body>
</html>


